xquery version "3.0";

declare variable $exist:path external;
declare variable $exist:resource external;
declare variable $exist:root external;
declare variable $exist:controller external;

let $domain := request:get-header("Host") return
if ($domain = ("www.exist-db.tk", "exist-db.tk")) then
    <dispatch xmlns="http://exist.sourceforge.net/NS/exist">
        
            <forward url="/tk/exist-db/controller.xql">
                <add-parameter name="exist:path" value="{$exist:path}"/>
                <add-parameter name="exist:resource" value="{$exist:resource}"/>
                <add-parameter name="exist:root" value="{$exist:root}"/>
                <add-parameter name="exist:controller" value="{$exist:controller}/exist-db"/>
            </forward>
        
    </dispatch>
else ()